package cn.lili.controller.system.goods_auth;

import cn.lili.common.utils.ResultUtil;
import cn.lili.common.vo.ResultMessage;
import cn.lili.modules.goods_auth.service.GoodsAuthService;
import cn.lili.modules.system.entity.dos.LiAuth;
import cn.lili.modules.system.entity.dto.GoodsAuthSearchParams;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;

@RestController
@AllArgsConstructor
@Api(tags = "商品授权管理")
@RequestMapping("/system/goods_auth")
public class GoodsAuthController {

    private GoodsAuthService goodsAuthService;

    @ApiModelProperty(value = "授权分页查询")
    @GetMapping("/page")
    public ResultMessage<Object> authPage(GoodsAuthSearchParams searchParams){
        return ResultUtil.data(goodsAuthService.authPage(searchParams));
    }

    @ApiModelProperty(value = "生成APPID，私钥，公钥")
    @PostMapping("/generateAppid")
    public ResultMessage<Object> generateAppid(){
        return ResultUtil.data(goodsAuthService.generateAppid());
    }

    @ApiModelProperty(value = "添加授权")
    @PostMapping("/add")
    public ResultMessage<Object> addAuth(@RequestBody LiAuth liAuth){
        return ResultUtil.data(goodsAuthService.addLiAuth(liAuth));
    }

    @ApiModelProperty(value = "修改授权")
    @PutMapping("/update")
    public ResultMessage<Object> updateAuth(@RequestBody LiAuth liAuth){
        return ResultUtil.data(goodsAuthService.updateAuth(liAuth));
    }

    @ApiModelProperty(value = "冻结")
    @GetMapping("/freeze")
    public ResultMessage<Object> freeze(@RequestParam String id){
        return ResultUtil.data(goodsAuthService.freeze(id));
    }

    @ApiModelProperty(value = "解冻")
    @GetMapping("/unFreeze")
    public ResultMessage<Object> unFreeze(@RequestParam String id){
        return ResultUtil.data(goodsAuthService.unFreeze(id));
    }
}
